package logic

import (
	"context"
	"errors"
	"medi-reserve/model"

	"medi-reserve/medirpc/internal/svc"
	"medi-reserve/medirpc/medirpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ReserveShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReserveShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReserveShowLogic {
	return &ReserveShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ReserveShowLogic) ReserveShow(in *medirpc.ReserveShowRequest) (*medirpc.ReserveShowResponse, error) {
	// todo: add your logic here and delete this line
	var goods model.Reserve
	err := goods.ReserveShow(model.DB, in.ReserveId)
	if err != nil {
		return nil, errors.New("没有找到该字段")
	}
	return &medirpc.ReserveShowResponse{
		Name:        goods.Name,
		ReserveCode: int64(goods.ReserveCode),
		WxName:      goods.WxName,
		Tel:         int64(goods.Tel),
		ReserveId:   int64(goods.ID),
	}, nil
}
